package com.yunhe.sms.service.impl;

import com.yunhe.sms.service.IndexService;
import com.yunhe.sms.service.system.PermissionService;
import com.yunhe.sms.service.system.impl.PermissionServiceImpl;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by Administrator on 2017/10/26 0026.
 */
public class IndexServiceImpl implements IndexService{
    PermissionService permissionService = new PermissionServiceImpl();


    @Override
    public Object loginJY(HttpServletRequest req) {

        HttpSession session = req.getSession();

        Object userName = session.getAttribute("userName");
        /*Object userName = null;*/
        if(null == userName){
            Cookie[] cookies = req.getCookies();
            if(null != cookies){
                for(Cookie c : cookies){
                    if(c.getName().equals("userName")){
                        userName = c.getValue();
                        break;
                    }
                }
            }
        }
        return userName;
    }
}
